// Karma configuration
// Generated on Wed Dec 06 2017 21:28:37 GMT+0800 (中国标准时间)
const path = require('path');

module.exports = function(config) {
  config.set({
      basePath: '',
      frameworks: ['mocha','chai'],
      files: [
          './test/*.spec.js'
      ],
      exclude: [],
      // webpack configuration
      webpack: require("./webpack.config.js"),
      webpackMiddleware: {
          stats: "errors-only"
      },
      reporters: ['progress','coverage','nyan'],
      preprocessors: {
          './src/**/*.js': ['webpack', 'sourcemap'],
          "./test/*.spec.js": ["webpack"]
      },
      nyanReporter: {
          suppressErrorHighlighting: true,
      },
      plugins: [
          'karma-mocha',
          'karma-chai',
          'karma-webpack',
          'karma-chrome-launcher',
          'karma-sourcemap-loader',
          'karma-nyan-reporter',
          'karma-coverage'
      ],
      port: 9876,
      colors: true,
      logLevel: config.LOG_INFO,
      autoWatch: true,
      browsers: ['ChromeWithoutSecurity'],
      customLaunchers: {
          ChromeWithoutSecurity: {
              base: 'Chrome'
          }
      },
      // Continuous Integration mode
      // if true, Karma captures browsers, runs the tests and exits
      singleRun: false,
      concurrency: Infinity,
      // 配置代码覆盖率插件
      // coverageIstanbulReporter: {
      //       // 以什么格式, 这里设置了输出 html文件 ,info文件 ,及控制台
      //       reports: ['html', 'lcovonly', 'text-summary'],
      //       // 将文件输出路径定位
      //       dir: path.join(__dirname, 'coverage'),
      //       // 修正 weback 路径（翻译了是这个意思）
      //       fixWebpackSourcePaths: true,
      //       // 将生成的html放到./coverage/html/下
      //       'report-config': {
      //           html: {
      //
      //           }
      //       }
      // },
      coverageReporter: {
          type: 'html', //produces a html document after code is run
          dir: path.join(__dirname, 'coverage'), //path to created html doc
      }
  })
}
